<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<style type="text/css">
#purchase_order_settle_info .box label span {
	display: inline-block;
	width: 74px;
	text-align: right;
}

#purchase_order_settle_info .box label {
	margin-right: 20px;
}

#purchase_order_settle_info .formBox {
	padding: 0;
	position: relative;
}

#purchase_order_settle_info .formBox>div {
	padding: 20px;
}

#purchase_order_settle_info .updateBox label span {
	width: 96px;
}
</style>
<div class="modal fade" id="purchase_order_settle_info" tabindex="-1" role="dialog"
	aria-labelledby="myModalLabel">
	<div class="modal-dialog" role="document" style="width: 360px;">
		<div class="modal-content">
			<div class="modal-header">
				<button type="button" class="close" data-dismiss="modal"
					aria-label="Close">
					<span aria-hidden="true">&times;</span>
				</button>
				<h4 class="modal-title" id="myModalLabel">采购结算</h4>
			</div>
			<form id="purchase_order_settle_form" class="form">
				<input type="hidden" name="purchaseOrderID" id="firstid">
				<div class="box modal-body">
					<p>
						<label>采购单号</label>
						<input type="text" class="form-control" name="orderNumber" readonly>
					</p>
					<p>
						<label>应付货款</label>
						<input type="text" class="form-control" name="shouldPay" readonly></input>
					</p>
					<p>
						<label>实付货款</label>
						<input type="text" class="form-control" name="actualPay"></input>
					</p>
				</div>
			</form>
			<div class="modal-footer">
				<button type="button" class="btn btn1" onclick="settlePurchaseOrder();">保存</button>
				<button type="button" class="btn btn2" data-dismiss="modal">取消</button>
			</div>
		</div>
	</div>
</div>
<script>

function confirmSettlePurchaseOrder(purchaseOrderID){
	$('#purchase_order_settle_info :text').val("");
	$.ajax({
		url:"<%=basePath %>purchaseOrder/toSettle.do",
		type:"post",
		async : false,
		dataType:"json",
		data:"purchaseOrderID="+purchaseOrderID,
		success:function(data){
			for(var key in data){
				$("#purchase_order_settle_info [name='"+key+"']").val(data[key]);
			}
		}
	});
	$('#purchase_order_settle_info').modal('show');
}

function settlePurchaseOrder(){
	if(!validateSettleForm()) return;
	$.ajax({
		url:"<%=basePath %>purchaseOrder/settle.do",
		type:"post",
		async : false,
		dataType:"json",
		data : $("#purchase_order_settle_form").serialize(),
		success:function(data){
			if(data.result=="success"){
				$('#purchase_order_settle_info :text').val("");
				$('#purchase_order_settle_info').modal('hide');
				Prompt.alert("提示","采购单结算成功！",Prompt.refresh)
			}else{
				Prompt.alert("提示","结算失败！")

			}
		},
		error :function(){
			Prompt.alert("提示","结算失败！")
		}
	});
}

function validateSettleForm(){
	
	return true;
}





</script>